package cn.hebutrun.oulabot.service.impl;

import cn.hebutrun.oulabot.common.config.OulaBotYamlConfig;
import cn.hebutrun.oulabot.common.util.BotUtil;
import cn.hebutrun.oulabot.entity.enums.MessageTypeEnum;
import cn.hebutrun.oulabot.entity.response.BotMessageResponse;
import cn.hebutrun.oulabot.service.IBotService;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author zhaolong
 * @since 2022-09-28
 */
@Service
@RequiredArgsConstructor
public class BotServiceImpl implements IBotService {

  private final OulaBotYamlConfig oulaBotYamlConfig;

  @Override
  public boolean isNotMaster(Long userId) {
    return !this.isMaster(userId);
  }

  @Override
  public boolean isMaster(Long userId) {
    return oulaBotYamlConfig.getMaster().contains(String.valueOf(userId));
  }

  /**
   * 只要说话就会发 "太呆啦"
   *
   * @param botMessageResponse 返回的消息实体
   * @param qq 个人qq账号
   * @since 2022/10/8
   * @author zhaolong
   */
  private void taidaila(BotMessageResponse botMessageResponse, String qq) {
    if (qq.equals(String.valueOf(botMessageResponse.getUserId()))
        && MessageTypeEnum.GROUP.getType().equals(botMessageResponse.getMessageType())) {
      BotUtil.sendMessage(botMessageResponse, StrUtil.format("[CQ:at,qq={}] ", qq) + "太呆啦");
    }
  }
}
